


{extend name="common/main"}

{block name="css"}
<!-- 本页面需要额外添加的css请在此处添加 -->
<link rel="stylesheet" type="text/css" href="/mobiled/css/login.css"/>


{/block}

{block name="body"}
<body>
<header id="header" class='header'>
	<div class="h-left"><a href="javascript:history.back(-1)"></a></div>
	<div class="h-mid">找回密码</div>
</header>
<div class="denglu">

		<div class="Login">
			<dl>
				<dt>手机号码：</dt>
				<dd><input type="text" name="mobile" id="mobile" maxlength="11" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="请输入手机号" value="" /></dd>
			</dl>
			<dl id="c_mobile_code" class="field auth-code v_item v_mobile">
				<dt>验证码：</dt>
				<div class="codeTxt">
					<input type="text" id="mobile_code" maxlength="4" onkeyup="this.value=this.value.replace(/\D/g,'')" name="mobile_code" placeholder="手机验证码" class="hq_phone" />
				</div>
				<input id="zphone" type="button" value="获取手机验证码" class="m_phone"  style="color:#FFF;width: 25%;"/>
			</dl>
			<dl style=" margin-top:15px;">
				<dt>新密码：</dt>
				<dd><input type="password" name="password" id="password" placeholder="请输入新密码"/></dd>
			</dl>
			<dl style=" margin-top:15px;">
				<dt>确认密码：</dt>
				<dd><input type="password" name="password" id="newpass" placeholder="请再次确认密码"/></dd>
			</dl>
			<div class="field submit-btn">
				<input type="button" class="btn_big1" onClick="checkSubmit()" value="确 定" />
			</div>

		</div>

</div>
<script src="/layer/layer.js"></script>

<script type="text/javascript">

    $("#zphone").click(btnCheck);
    /**
     * [btnCheck 按钮倒计时常用于获取手机短信验证码]
     */
    function btnCheck() {
        $mobile = $('#mobile').val();
		if ($mobile.length ==11){
            $.ajax({
                type : 'post',
                url : "{:url('smsver')}",
                data : {
				'mobile':$mobile
            	},
                success : function(res){
                    if (res.code != 200) {
                        layer.msg(res.msg,{shade: 0.5, time: 2000, icon: 2});
                        return false;
                    }
                    layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function(){
                        $(this).addClass("on");
                        var time = 60;
                        $(this).attr("disabled", true);
                        var timer = setInterval(function() {
                            if (time == 0) {
                                clearInterval(timer);
                                $("#zphone").attr("disabled", false);
                                $("#zphone").val("获取验证码");
                                $("#zphones").removeClass("on");
                            } else {
                                $('#zphone').val(time + "秒");
                                time--;
                            }
                        }, 1000);
                    });

                }
            })
    }else{
            layer.msg('请填写11位手机号码',{shade: 0.5, time: 2000, icon: 2});
            return false;
    }

    }

    function checkSubmit() {
		$mobile = $('#mobile').val();
		$mobile_code = $('#mobile_code').val();
		$password = $('#password').val();
		$newpass= $('#newpass').val();
        $.ajax({
            type: 'post',
            url: "{:url('changepwd')}",
            data: {
                'mobile': $mobile,
				'mobile_code':$mobile_code,
				'password':$password,
				'newpass':$newpass
            },
            dataType: 'json',
            success: function (res) {
                if (res.code != 200) {
                    layer.msg(res.msg,{shade: 0.5, time: 2000, icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function(){
                    window.location.href="{:url('login')}";//跳转登陆页
                });
            }
        })
    }
</script>
{include file="common/bar"}
</body>
{/block}

{block name="js"}
{include file='common:validation'}

<!-- 本页面需要额外添加的js请在此处添加 -->



{/block}